package com.yule.mq.producer;

import com.yule.system.model.SystemLog;
import com.yule.system.model.SystemUser;
import com.yule.vo.LogModuleVo;
import com.yule.vo.LogOperateVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Queue;
import java.util.Date;

@Component
public class SystemLogProducer {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private Queue queue;

    public void sendLog(SystemLog systemLog) {
        this.jmsMessagingTemplate.convertAndSend(this.queue, systemLog);
    }
    
    public void sendLog(String code, LogOperateVo logOperateVo, LogModuleVo logModuleVo, SystemUser user) {
    	this.sendLog(new SystemLog(user, logOperateVo.getKey(), logModuleVo.getKey(), code, new Date()));
    }

}
